package com.dreamchaser.familydevice.service;

import com.dreamchaser.familydevice.domain.dto.DeviceExpression;
import io.netty.channel.Channel;

/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 *
 *
 * @author: SJie
 * @Date: 2020/8/16 21:23
 * @description: 设备相关操作
 *
 */
public interface IDeviceService {

    /**
     * 验证设备是否被注册
     * @param deviceId
     * @return
     */
    boolean validDevice(int deviceId);

    void setComStatus(int deviceId, int comId, int status);

    /**
     * 发送初始化状态指令
     * @param deviceCode
     * @param channel
     */
    void sendInitStatus(int deviceCode, Channel channel);

    /**
     * 设置设备状态
     * @param deviceExpressionBydeviceCode
     * @param data
     */
    void setDeviceStatus(DeviceExpression deviceExpressionBydeviceCode, byte[] data);

    /**
     * 刷新设备状态，有改变则发送指令
     * @param deviceExpressionBydeviceCode
     * @param data
     * @param channel
     */
    void refreshDeviceStatus(DeviceExpression deviceExpressionBydeviceCode, byte data, Channel channel);

    /**
     * 解析内置函数并处理
     * @param deviceCode
     * @param internalFunc
     * @param data
     * @return
     */
    boolean analyseInternalFunc(int deviceCode, String internalFunc, int data);
}
